<?php
require_once '../controls/global.php';
$login_admin = new user_controller();
$action = "";
if (isset($_POST['btn_submit'])) {
    $_username = $_POST['username'];
    $_password = $_POST['password'];
    $_ck_remember = $_POST['ck_remember'];
    $login_admin->admin_login($_username, $_password , $_ck_remember);
}
if( isset($_COOKIE["username"]) && isset($_COOKIE["password"]) && $_COOKIE["password"] != "out" && $_COOKIE["username"] != "log"){
    //exit;
    $_username = $_COOKIE["username"];
    $_password = $_COOKIE["password"];
    $_ck_remember = "check";
    $login_admin->admin_login($_username, $_password, $_ck_remember);
}
if (isset($_GET['action']) && $_GET['action']== 'logout'){
    $login_admin->logout();
    header("Location:../views/admin_login.php");
}
if (($_SESSION['user']->role != 1)||($_SESSION['user']->username == "")) {
    include("../views/admin_login.php");
    include("../templates/admin_footer.php");
}else{
    include('../templates/admin_header.php');
    if(($action == 'user')||($action == ''))
    {
        include("../views/admin_users.php");
    }elseif($action == 'cms'){
        include("../views/admin_cms.php");
    }elseif($action == 'battles')
    {
    include('../views/admin_battles.php');
    }
    include("../templates/admin_footer.php");
}
?>